<template>
  <div class="user-score-list-container">
    <van-list v-if="showList"
      v-model="listView.loading"
      :finished="listView.finished"
      finished-text="没有更多了"
      @load="loadList">
      <van-cell class="score-item" :title="score.showType" :value="score.num > 0 ? '+'+score.num : '-'+score.num" size="large" :label="score.signDate" v-for="(score, index) in listView.list" :key="index"/>
    </van-list>
    <van-empty v-if="!showList"
      image="imgs/empty.png"
      description="暂无积分记录~"
    />
  </div>
</template>

<script>
import { mapState } from 'vuex'
import constants from '@/config/constants'
import userApi from '@/api/userApi'
import utils from '@/utils/utils'

export default {
  name: 'userScoreList',
  props: ['status'],
  computed: {
    ...mapState(['user'])
  },
  data () {
    return {
      showList: true,
      /* 积分流水列表 */
      listView: {
        params: {
          memberId: '',
          status: '-1',
          pageNo: 1,
          pageSize: 10
        },
        loading: false,
        finished: false,
        list: []
      }
    }
  },
  methods: {
    /* 获取列表 */
    loadList() {
      this.listView.params.memberId = this.user.id;
      this.listView.params.status = this.status;
      userApi.scoreList(this.listView.params).then(result => {
				if(result.code == constants.SUCCESS){
					utils.pageResultHandle(this.listView, result.data);
					if(result.data.totalCount == 0){
					  this.showList = false;
					}
				}
      })
    }
  }
}
</script>

<style lang="scss">
.user-score-list-container{
  margin-top: 10px;
  margin-bottom: 20px;
  .score-item{
    height: 80px;
    padding: 15px 25px;
    border-bottom: 1px solid #dfdfdf;
    .van-cell__title{
      font-size: 14px;
    }
    .van-cell__label{
      font-size: 13px;
    }
    .van-cell__value{
      font-size: 14px;
      color: #e6b873;
      line-height: 50px;
    }
  }
}
</style>
